import call
import time, threading
from pyTimeManager import *

# myTimeManager = PyTimeManager()
# settings = myTimeManager.openUsersSettings()
# clocks = myTimeManager.openUsersClocks()

clocks = [{'clockName':'test','ringTime':[2018,2,22,19,31],'repeat':'onc'}]

clocksTimes = []
for i in clocks:
	clocksTimes.append(i['ringTime'])

clocksNames = []
for i in clocks:
	clocksNames.append(i['clockName'])

clocksrepeats = []
for i in clocks:
	clocksrepeats.append(i['repeat'])



while True:
	while time.localtime(time.time())[5] != 0:
		time.sleep(1)
	now = time.localtime(time.time())
	j = 0
	print(clocksTimes)
	for i in clocksTimes:
		print(i)
		if i[3] == now[3] and i[4] == now[4] and (\
			i[2] == now[2] and i[1] == now[1] and \
			i[0] == now[0] and 'onc' in clocksrepeats[j] \
			or 'evd' in clocksrepeats[j] or \
			now[6] in formatWeekList(clocksrepeats[j]) or \
			'evm' in clocksrepeats[j] and \
			i[2] == now[2] or 'evy' in clocksrepeats[j] and \
			i[2] == now[2] and i[1] == now[1]):
			call = threading.Thread(target=call.ring,args=(
				clocksNames[j], True))# settings['playSound']
			call.start()
		j += 1
	
